home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / mib / mibDrawArea.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  2.5 KB  |  108 lines

  1. #include "mibload.h"
  2. #include "mibwidgets.h"
  3.  
  4. extern Display    *dpy;
  5. extern GC     mib_gc;
  6.  
  7. /* Code for DrawingArea */
  8. /*****************************************************************************/
  9.  
  10. mib_Widget *mib_create_DrawingArea(mib_Widget *parent, char *name, char *label,
  11.     int posx, int posy, int width, int height, int mib_fill)
  12. {
  13.   mib_Widget        *temp;
  14.   mib_DrawingArea    *myres;
  15.   Widget         wtemp;
  16.   Arg             args[20];
  17.   int             n;
  18.  
  19.   /* create the new widget and add it to the tree */
  20.  
  21.   temp = mib_new_mib_Widget();
  22.   if (mib_fill == WDEFAULT)
  23.     mib_add_backward(temp, parent);
  24.   else
  25.     mib_add_mib_Widget(temp, parent);
  26.   myres = (mib_DrawingArea *)malloc(sizeof(mib_DrawingArea));
  27.  
  28.   /* initialize public resources */
  29.  
  30.   if (mib_fill == WDEFAULT)
  31.   {
  32.     temp->name = (char *)malloc(strlen(name)+1);
  33.     strcpy(temp->name,name);
  34.   }
  35.   temp->mib_class = (char *)malloc(12);
  36.   sprintf(temp->mib_class,"DrawingArea");
  37.   temp->mib_class_num = MIB_DRAWINGAREA;
  38.   temp->width = width;
  39.   temp->height = height;
  40.   temp->topOffset = posy;
  41.   temp->leftOffset = posx;
  42.   temp->bottomOffset = 0;
  43.   temp->rightOffset = 0;
  44.   temp->topAttachment = 1;
  45.   temp->leftAttachment = 1;
  46.   temp->bottomAttachment = 0;
  47.   temp->rightAttachment = 0;
  48.  
  49.   temp->mib_allowresize = 1;
  50.  
  51.   /* initialize private resources */
  52.  
  53.   temp->myres = (void *)myres;
  54.   myres->nothing = 0;
  55.  
  56.   /* create Xt widget */
  57.  
  58.  
  59.   n = 0;
  60.   if (mib_fill == WDEFAULT)
  61.   {
  62.     XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  63.     XtSetArg (args[n], XmNleftOffset, posx);n++;
  64.     XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  65.     XtSetArg (args[n], XmNtopOffset, posy);n++;
  66.     XtSetArg (args[n], XmNwidth, width); n++;
  67.     XtSetArg (args[n], XmNheight, height); n++;
  68.   }
  69.  
  70.   XtSetArg (args[n], XmNbackground, WhitePixel(dpy, DefaultScreen(dpy))); n++;
  71.   XtSetArg (args[n], XmNrubberPositioning, False); n++;
  72.   XtSetArg (args[n], XmNhighlightThickness, 0); n++;
  73.  
  74.   temp->me = XtCreateManagedWidget(name, xmDrawingAreaWidgetClass,
  75.                 temp->parent->me, args, n);
  76.   if (mib_fill == WEDIT || mib_fill == WDEFAULT)
  77.   {
  78.     mib_apply_eventhandlers(temp->me, temp);
  79.   }
  80.  
  81.   return temp;
  82. }
  83.  
  84. void mib_delete_DrawingArea(mib_Widget *this)
  85. {
  86.   mib_DrawingArea *temp = (mib_DrawingArea *)this->myres;
  87.  
  88.   free(temp);
  89. }
  90.  
  91. void mib_save_DrawingArea(mib_Widget *this, FILE *fout)
  92. {
  93. }
  94.  
  95. int mib_load_DrawingArea(mib_Widget *this, mib_Buffer *fin)
  96. {
  97.   char          res[MI_MAXSTRLEN];
  98.   char          val[MI_MAXSTRLEN];
  99.  
  100.   if (!mib_read_line(fin, res, val))
  101.     return 0;
  102.  
  103.   if (strcmp(res,"EndWidget"))
  104.     return 0;
  105.  
  106.   return 1;
  107. }
  108.